package com.view.web.controller.show;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.view.system.domain.TblApplicationInfo;
import com.view.system.service.ITblApplicationInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.view.common.annotation.Log;
import com.view.common.core.controller.BaseController;
import com.view.common.core.domain.AjaxResult;
import com.view.common.enums.BusinessType;
import com.view.common.utils.poi.ExcelUtil;
import com.view.common.core.page.TableDataInfo;

/**
 * 申请数据Controller
 * 
 * @author lz
 * @date 2024-03-01
 */
@RestController
@RequestMapping("/show/info")
public class TblApplicationInfoController extends BaseController
{
    @Autowired
    private ITblApplicationInfoService tblApplicationInfoService;

    /**
     * 查询申请数据列表
     */
    @PreAuthorize("@ss.hasPermi('show:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(TblApplicationInfo tblApplicationInfo)
    {
        startPage();
        List<TblApplicationInfo> list = tblApplicationInfoService.selectTblApplicationInfoList(tblApplicationInfo);
        return getDataTable(list);
    }

    /**
     * 导出申请数据列表
     */
    @PreAuthorize("@ss.hasPermi('show:info:export')")
    @Log(title = "申请数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TblApplicationInfo tblApplicationInfo)
    {
        List<TblApplicationInfo> list = tblApplicationInfoService.selectTblApplicationInfoList(tblApplicationInfo);
        ExcelUtil<TblApplicationInfo> util = new ExcelUtil<TblApplicationInfo>(TblApplicationInfo.class);
        util.exportExcel(response, list, "申请数据数据");
    }

    /**
     * 获取申请数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('show:info:query')")
    @GetMapping(value = "/{applyId}")
    public AjaxResult getInfo(@PathVariable("applyId") String applyId)
    {
        return success(tblApplicationInfoService.selectTblApplicationInfoByApplyId(applyId));
    }

    /**
     * 新增申请数据
     */
    @PreAuthorize("@ss.hasPermi('show:info:add')")
    @Log(title = "申请数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TblApplicationInfo tblApplicationInfo)
    {
        return toAjax(tblApplicationInfoService.insertTblApplicationInfo(tblApplicationInfo));
    }

    /**
     * 修改申请数据
     */
    @PreAuthorize("@ss.hasPermi('show:info:edit')")
    @Log(title = "申请数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TblApplicationInfo tblApplicationInfo)
    {
        return toAjax(tblApplicationInfoService.updateTblApplicationInfo(tblApplicationInfo));
    }

    /**
     * 删除申请数据
     */
    @PreAuthorize("@ss.hasPermi('show:info:remove')")
    @Log(title = "申请数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyIds}")
    public AjaxResult remove(@PathVariable String[] applyIds)
    {
        return toAjax(tblApplicationInfoService.deleteTblApplicationInfoByApplyIds(applyIds));
    }
}
